<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>滴答办公系统-班级列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/media/layui/css/layui.css" media="all">
    <script src="/media/js/jquery.min.js"></script>
</head>
<body>
<div class="layui-container">
    <table class="layui-table" id="tbdata" lay-filter="tbop">
        <thead>
        <tr>
            <td>序号</td>
            <td>班级名称</td>
            <td>班级人数</td>
            <td>学科名称</td>
            <td>周数</td>
            <td>位置</td>
            <td>开班日期</td>
            <td>操作</td>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${pageUtils.recordsl}" var="cl">
            <tr>
                <td>${cl.id}</td>
                <td>${cl.className}</td>
                <td>12</td>
                <td>${cl.majorname}</td>
                <td>${cl.classTime}</td>
                <td>${cl.classAddress}</td>
                <td>${cl.classDate}</td>
                <td><a class="layui-btn layui-btn-mini" >编辑</a>
                    <a class="layui-btn layui-btn-danger layui-btn-mini" onclick="deleteCourse(${cl.id},${pageUtils.pageIndex},${pageUtils.pageSize});">删除</a> </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
    <div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-1">
        <c:if test="${pageUtils.pageIndex==1}">
            <a href="#" class="layui-laypage-prev layui-disabled" data-page="0">
                <i class="layui-icon">&lt;</i>
            </a>
        </c:if>

        <c:if test="${pageUtils.pageIndex!=1}">
            <a href="/Tclasspage/${pageUtils.pageIndex-1}/${pageUtils.pageSize}" class="layui-laypage-prev" data-page="0">
                <i class="layui-icon">&lt;</i>
            </a>
        </c:if>

       <c:forEach begin="${pageUtils.numberStart}" end="${pageUtils.numberEnd}" step="1" var="num">
           <a href="/Tclasspage/${num}/${pageUtils.pageSize}">${num}</a>
       </c:forEach>

        <c:if test="${pageUtils.pageIndex==pageUtils.pageCount}" >
            <a href="#" class="layui-laypage-next layui-disabled" data-page="2">
                <i class="layui-icon">&gt;</i>
            </a>
        </c:if>

        <c:if test="${pageUtils.pageIndex!=pageUtils.pageCount}">
            <a href="/Tclasspage/${pageUtils.pageIndex+1}/${pageUtils.pageSize}" class="layui-laypage-next " data-page="2">
                <i class="layui-icon">&gt;</i>
            </a>
        </c:if>

        <span class="layui-laypage-skip">到第
							   <input type="text" min="1" value=${pageUtils.pageIndex}  class="layui-input" id="context">页
								<button type="button" class="layui-laypage-btn" onclick="topage()">确定</button>
							</span>
        <span class="layui-laypage-count">共${pageUtils.allCount}条</span>
        <span class="layui-laypage-limits">
							    <select lay-ignore="" onchange="topagesize(this)">
							        <option value="5" ${pageUtils.pageSize==5?"selected":""}>5 条/页</option>
									<option value="10" ${pageUtils.pageSize==10?"selected":""}>10 条/页</option>
									<option value="15" ${pageUtils.pageSize==15?"selected":""}>15 条/页</option>
							</select>
							</span>
    </div>
</div>
<script src="https://cdn.bootcdn.net/ajax/libs/layui/2.4.3/layui.all.js"></script>
<%--<script src="/media/layui/layui.js"></script>--%>

<script type="text/javascript">
    function deleteCourse(id,ind,size){
        layui.use('table', function() {
            layer.confirm('是否确认删除班级?',function(index) {
                $.getJSON("/Tclassdel",{"id":id},function(result){
                    if(result.status==200){
                        layer.msg("删除成功", {icon : 6});
                        location.href="/Tclasspage/"+ind+"/"+size;
                    }else{
                        layer.msg("删除失败", {icon : 5});
                    }
                })


            });
        });
    }

    /**
     * 页面大小转换
     */
    function topagesize(select){
       location.href="/Tclasspage/1/"+$(select).val();
    }

    /**
     * 页面跳转
     */
    function topage(){
        if($("#context").val()<=${pageUtils.pageCount}){
            location.href="/Tclasspage/"+$("#context").val()+"/"+${pageUtils.pageSize};
        }else{
           layer.msg("请重新输入");
        }
    }
</script>

</body>
</html>